<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        #test{
            width:100px;
            height: 100px;
            
        }
    </style>
</head>
<body>
    <div id="test" style="background: #abcdef;"></div>
    <script>
        var test = document.getElementById("test");
        //element.style.cssAttr -->获取的是内联样式（即直接写在元素后面的样式）
        // var bg = test.style.backgroundColor;
        var bg = getComputedStyle(test).backgroundColor;
        console.log(bg);
    </script>
</body>
</html>